
package com.wpen.unit.web.controller.job;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wpen.unit.service.job.AgentExecLogService;
import com.wpen.unit.service.job.BatchExecLogService;
import com.wpen.unit.service.job.JobExec1LogService;
import com.wpen.unit.service.job.RedoExecLogService;
import com.wpen.unit.service.job.TaskExecLogService;
import com.wpen.unit.web.dto.job.AgentExec1LogDetailRequest;
import com.wpen.unit.web.dto.job.AgentExec1LogDetailResponse;
import com.wpen.unit.web.dto.job.AgentExec1LogListRequest;
import com.wpen.unit.web.dto.job.AgentExec1LogListResponse;
import com.wpen.unit.web.dto.job.BatchAllLogListRequest;
import com.wpen.unit.web.dto.job.BatchExecLogListRequest;
import com.wpen.unit.web.dto.job.BatchExecLogListResponse;
import com.wpen.unit.web.dto.job.BatchExecRedoRequest;
import com.wpen.unit.web.dto.job.BatchExecRedoResponse;
import com.wpen.unit.web.dto.job.BatchExecRedologListRequest;
import com.wpen.unit.web.dto.job.BatchExecRedologListResponse;
import com.wpen.unit.web.dto.job.BatchInfoMtRunningRequest;
import com.wpen.unit.web.dto.job.BatchInfoMtRunningResponse;
import com.wpen.unit.web.dto.job.JobExec1LogDetailRequest;
import com.wpen.unit.web.dto.job.JobExec1LogDetailResponse;
import com.wpen.unit.web.dto.job.JobExec1LogListRequest;
import com.wpen.unit.web.dto.job.JobExec1LogListResponse;
import com.wpen.unit.web.dto.job.JobExec1RedoRequest;
import com.wpen.unit.web.dto.job.JobExec1RedoResponse;
import com.wpen.unit.web.dto.job.JobExec1RedologListRequest;
import com.wpen.unit.web.dto.job.JobExec1RedologListResponse;
import com.wpen.unit.web.dto.job.JobExec1StopRequest;
import com.wpen.unit.web.dto.job.JobExec1StopResponse;
import com.wpen.unit.web.dto.job.JobExecAgentLogListRequest;
import com.wpen.unit.web.dto.job.JobExecAgentLogListResponse;
import com.wpen.unit.web.dto.job.TaskExecLogListRequest;
import com.wpen.unit.web.dto.job.TaskExecLogListResponse;
import com.wpen.unit.web.dto.job.TaskExecRedoRequest;
import com.wpen.unit.web.dto.job.TaskExecRedoResponse;
import com.wpen.unit.web.dto.job.TaskExecRedologListRequest;
import com.wpen.unit.web.dto.job.TaskExecRedologListResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 批次执行日志维护
 * 
 * @author pg
 *
 */
@Tag(name = "批次执行日志模块服务接口")
@RestController
@RequestMapping("/api")
public class ExecLogController {
	@Autowired
	private BatchExecLogService batchExecLogService;
	@Autowired
	private TaskExecLogService taskExecLogService;
	@Autowired
	private JobExec1LogService jobExec1LogService;
	@Autowired
	private AgentExecLogService agentExecLogService;
	@Autowired
	private RedoExecLogService redoExecLogService;

	@Operation(summary = "批次执行计划日志-列表查询")
	@PostMapping(value = "/batchAllLog/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public TaskExecLogListResponse queryListBatchAllLog(
			@RequestBody @Valid BatchAllLogListRequest taskExecLogListRequest) {
		return taskExecLogService.queryListBatchAllExecLog(taskExecLogListRequest);
	}
	
	/////////// --------------------------批次------------------------ **/

	@Operation(summary = "批次执行日志-列表查询")
	@PostMapping(value = "/batchExecLog/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public BatchExecLogListResponse queryListBatchExecLog(
			@RequestBody @Valid BatchExecLogListRequest batchExecLogListRequest) {
		return batchExecLogService.queryListBatchExecLog(batchExecLogListRequest);
	}

	@Operation(summary = "批次执行日志-列表查询")
	@PostMapping(value = "/batchExecLog/redo/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public BatchExecRedologListResponse queryListBatchExecRedolog(
			@RequestBody @Valid BatchExecRedologListRequest batchExecRedologListRequest) {
		return batchExecLogService.queryListBatchExecRedolog(batchExecRedologListRequest);
	}

	@Operation(summary = "批次执行日志-修改")
	@PostMapping(value = "/batchExecLog/redo", produces = MediaType.APPLICATION_JSON_VALUE)
	public BatchExecRedoResponse redoBatchExec(@RequestBody @Valid BatchExecRedoRequest batchExecRedoRequest) {
		return batchExecLogService.redoBatchExec(batchExecRedoRequest);
	}
	
    @Operation(summary = "批次信息-手工执行")
    @PostMapping(value = "/batchExecLog/mt-running", produces = MediaType.APPLICATION_JSON_VALUE)
    public BatchInfoMtRunningResponse mtRunBatchInfo(@RequestBody @Valid BatchInfoMtRunningRequest batchInfoMtRunningRequest) {
        return batchExecLogService.mtRunBatchInfo(batchInfoMtRunningRequest);
    }
	
	/////////// --------------------------任务------------------------ **/

	@Operation(summary = "任务执行日志-列表查询")
	@PostMapping(value = "/taskExecLog/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public TaskExecLogListResponse queryListTaskExecLog(
			@RequestBody @Valid TaskExecLogListRequest taskExecLogListRequest) {
		return taskExecLogService.queryListTaskExecLog(taskExecLogListRequest);
	}

	@Operation(summary = "任务执行日志-重跑历史-列表查询")
	@PostMapping(value = "/taskExecLog/redo/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public TaskExecRedologListResponse queryListTaskExecRedolog(
			@RequestBody @Valid TaskExecRedologListRequest taskExecRedologListRequest) {
		return taskExecLogService.queryListTaskExecRedolog(taskExecRedologListRequest);
	}

	@Operation(summary = "任务执行-重跑")
	@PostMapping(value = "/taskExecLog/redo", produces = MediaType.APPLICATION_JSON_VALUE)
	public TaskExecRedoResponse redoTaskExeclog(@RequestBody @Valid TaskExecRedoRequest taskExecRedoRequest) {
		return redoExecLogService.redoTaskExeclog(taskExecRedoRequest);
	}

	/////////// --------------------------作业------------------------ **/

	@Operation(summary = "任务作业执行1日志-列表查询")
	@PostMapping(value = "/jobExec1Log/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public JobExec1LogListResponse queryListJobExec1Log(
			@RequestBody @Valid JobExec1LogListRequest jobExec1LogListRequest) {
		return jobExec1LogService.queryListJobExec1Log(jobExec1LogListRequest);
	}

	@Operation(summary = "任务作业执行1日志-明细查询")
	@PostMapping(value = "/jobExec1Log/detail", produces = MediaType.APPLICATION_JSON_VALUE)
	public JobExec1LogDetailResponse detailJobExec1Log(
			@RequestBody @Valid JobExec1LogDetailRequest jobExec1LogDetailRequest) {
		return jobExec1LogService.detailJobExec1Log(jobExec1LogDetailRequest);
	}

	@Operation(summary = "任务作业执行1日志-重跑历史-列表查询")
	@PostMapping(value = "/jobExec1Log/redo/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public JobExec1RedologListResponse queryListJobExec1Redolog(
			@RequestBody @Valid JobExec1RedologListRequest jobExec1RedologListRequest) {
		return jobExec1LogService.queryListJobExec1Redolog(jobExec1RedologListRequest);
	}

	@Operation(summary = "任务作业执行1日志-重跑")
	@PostMapping(value = "/jobExec1Log/redo", produces = MediaType.APPLICATION_JSON_VALUE)
	public JobExec1RedoResponse redoJobExec1(@RequestBody @Valid JobExec1RedoRequest jobExec1RedoRequest) {
		return redoExecLogService.redoJobExec1(jobExec1RedoRequest);
	}
	
	@Operation(summary = "任务作业执行1-终止")
	@PostMapping(value = "/jobExec1Log/stop", produces = MediaType.APPLICATION_JSON_VALUE)
	public JobExec1StopResponse stopJobExec1(@RequestBody @Valid JobExec1StopRequest jobExec1StopRequest) {
		return redoExecLogService.stopJobExec1(jobExec1StopRequest);
	}
	
	@Operation(summary = "任务作业执行-执行器-列表查询")
	@PostMapping(value = "/jobExec1Log/agent/logs", produces = MediaType.APPLICATION_JSON_VALUE)
	public JobExecAgentLogListResponse queryListJobAgentLog(
			@RequestBody @Valid JobExecAgentLogListRequest jobExecAgentLogListRequest) {
		return jobExec1LogService.queryListExecAgentLog(jobExecAgentLogListRequest);
	}

	/////////// --------------------------执行器------------------------ **/

	@Operation(summary = "任务执行器日志-列表查询")
	@PostMapping(value = "/agent/exec/logs", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentExec1LogListResponse queryListAgentExecLog(
			@RequestBody @Valid AgentExec1LogListRequest agentExecLogListRequest) {
		return agentExecLogService.queryListAgentExecLog(agentExecLogListRequest);
	}
	


	@Operation(summary = "任务执行器1日志-明细查询")
	@PostMapping(value = "/agent/exec/log/detail", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentExec1LogDetailResponse detailAgentExec1Log(
			@RequestBody @Valid AgentExec1LogDetailRequest agentExec1LogDetailRequest) {
		return agentExecLogService.detailAgentExec1Log(agentExec1LogDetailRequest);
	}

}
